package c.x.jy.wexin.controller;

import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.R;
import c.x.jy.dao.entity.OrderItemsEntity;
import c.x.jy.service.service.OrderItemsService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 订单项目明细表
 *
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-05-25 10:50:45
 */
@RestController
@RequestMapping("wechat/orderitems")
public class OrderItemsController {
    @Autowired
    private OrderItemsService orderItemsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderItemsService.queryPage(params);

        return R.put(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("order:orderitems:info")
    public R info(@PathVariable("id") Long id){
		OrderItemsEntity orderItems = orderItemsService.getById(id);

        return R.put(orderItems);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("order:orderitems:save")
    public R save(@RequestBody OrderItemsEntity orderItems){
		orderItemsService.save(orderItems);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("order:orderitems:update")
    public R update(@RequestBody OrderItemsEntity orderItems){
		orderItemsService.updateById(orderItems);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    @RequiresPermissions("order:orderitems:delete")
    public R delete(@PathVariable("id") Long id){
		orderItemsService.removeByIds(Arrays.asList(id));

        return R.ok();
    }

}

